import java.util.jar.Attributes.Name;

import estereos.jamake.JamakeTools;
import estereos.jamake.factories.FileFactory;
import estereos.jamake.factories.ToolsFactory;

public class Build extends JamakeTools {

	public void build(String[] sArgs) {
		ToolsFactory.setToolsVerbose(true);
		setLogLevel(3);

		String sProjectName = FileFactory.getCurDirFile().getName();

		printSourceLink();

		javac.setSource("1.4");
		javac.setTarget("1.4");
		javac.setDestination("./jamake/classes");
		javac.run("./src");

		timer.splitwatch("Compilation");

		copy("./doc", "./jamake/classes/doc");

		timer.splitwatch("Javadoc");

		jar.setBasePath("./jamake/classes");
		jar.setDestFile("./jamake/jars/" + sProjectName + "-" + todayVersion()
				+ ".jar");
		jar.setLevel(jar.I_LEVEL_BEST_COMPRESSION);
		jar.setSort(true);
		jar.setManifestAttr(Name.CLASS_PATH, "doc");
		jar.setManifestAttr(Name.IMPLEMENTATION_TITLE, sProjectName);
		jar.run();
		delete("./jamake/classes/");

		timer.splitwatch("Binary packaging");

		zip.setBasePath("./");
		zip.setDestFile("./jamake/jars/" + sProjectName + "-src-"
				+ todayVersion() + ".zip");
		zip.setLevel(jar.I_LEVEL_BEST_COMPRESSION);
		zip.setSort(true);
		zip.addInclude(".*/" + sProjectName + "/src/.*");
		zip.run();

		timer.splitwatch("Sources packaging");

	}

	public static void main(String[] args) {
		project(args);
	}

}
